home *** CD-ROM | disk | FTP | other *** search
- Path: senator-bedfellow.mit.edu!tada
- From: tada@athena.mit.edu (Michael J Zehr)
- Newsgroups: comp.std.c
- Subject: setjmp usage question
- Date: 24 Feb 1996 21:10:50 GMT
- Organization: Massachusetts Institute of Technology
- Message-ID: <4gnusq$7be@senator-bedfellow.MIT.EDU>
- NNTP-Posting-Host: carbonara.mit.edu
-
-
- I'm trying to determine whether a particular usage of setjmp is
- sanctioned by the standard and I'm finding a compiler bug or whether my
- usage is non-conforming. My code boils down to this:
-
- jmp_buf env[10];
- int env_index;
-
- void func(int *error_code)
- {
- env_index = 0;
-
- if (*error_code = setjmp(env[env_index++])) {
- /* can env_index == 1 here? */
- return;
- }
- env_index--;
- longjmp(env[env_index], 1);
- }
-
- Should this code work correctly? In particular, can a compiler
- increment env_index after longjmp is called?
-
- [Additional question because I'm curious: what happens to
- post-increments that are in parameters of the longjmp call? Are they
- ever executed? I suppose the general question is where are the sequence
- points when you're using setjmp and lonjmp?]
-
- Thanks for any help,
- michael j zehr
-
-